package kr.co.goodwilldd.controller.common;

import kr.co.goodwilldd.service.board.IBoardService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 
 * @author GoodwillDD (kr.goodwilldd@gmail.com)
 * 
 *         <pre>
 * 	- bs type 	: 게시판 타입
 * 	- bt seq  	: 게시판 SEQ
 * 	- f first 	: 대분류
 * 	- s second 	: 중분류
 * 	- t third 	: 소분류
 * </pre>
 */
@Controller
@RequestMapping(value = "B{boardSeq:\\S+}")
public class MasterBoardController {

	private static final Logger logger = LoggerFactory
			.getLogger(MasterBoardController.class);

	@Autowired
	IBoardService boardService;

	/**
	 * 검색 및 페이징 : 검색은 제목 및 내용
	 * 
	 * @param model
	 * @param boardSeq
	 * @param cpage
	 * @param searchValue
	 * @return
	 */
	@RequestMapping(value = "list/page{cpage:\\d+}")
	public String list(Model model, @PathVariable("boardSeq") Integer boardSeq,
			@PathVariable("cpage") Integer cpage,
			@RequestParam(value = "searchKey", required = false) String searchKey,
			@RequestParam(value = "searchValue", required = false) String searchValue) {
		model.addAttribute("boardList",
				boardService.getList(boardSeq, cpage, searchKey, searchValue));
		return "board/list";
	}
	
}
